home *** CD-ROM | disk | FTP | other *** search
/ All for Cell Phones: Sony Ericsson / Sony-Ericsson 2004.iso / Java / imageviewer / ImageViewer.jar / Database.class (.txt) next >
Encoding:
Java Class File  |  2002-05-23  |  2.1 KB  |  83 lines

  1. import java.util.Vector;
  2. import javax.microedition.rms.RecordComparator;
  3. import javax.microedition.rms.RecordEnumeration;
  4. import javax.microedition.rms.RecordFilter;
  5. import javax.microedition.rms.RecordStore;
  6.  
  7. class Database {
  8.    // $FF: renamed from: rs javax.microedition.rms.RecordStore
  9.    protected RecordStore field_0;
  10.    protected Vector ids = new Vector();
  11.  
  12.    Database(String var1) {
  13.       try {
  14.          this.field_0 = RecordStore.openRecordStore(var1, true);
  15.          RecordEnumeration var2 = this.field_0.enumerateRecords((RecordFilter)null, (RecordComparator)null, false);
  16.  
  17.          while(var2.hasPreviousElement()) {
  18.             this.ids.addElement(new Integer(var2.previousRecordId()));
  19.          }
  20.  
  21.          var2.destroy();
  22.       } catch (Exception var3) {
  23.       }
  24.  
  25.    }
  26.  
  27.    void close() {
  28.       try {
  29.          this.field_0.closeRecordStore();
  30.       } catch (Exception var2) {
  31.       }
  32.  
  33.    }
  34.  
  35.    int getIndex(int var1) {
  36.       return this.ids.indexOf(new Integer(var1));
  37.    }
  38.  
  39.    int getId(int var1) {
  40.       return (Integer)this.ids.elementAt(var1);
  41.    }
  42.  
  43.    int numRecords() {
  44.       return this.ids.size();
  45.    }
  46.  
  47.    byte[] getRecord(int var1) {
  48.       try {
  49.          return this.field_0.getRecord(var1);
  50.       } catch (Exception var3) {
  51.          return null;
  52.       }
  53.    }
  54.  
  55.    boolean addRecord(byte[] var1) {
  56.       try {
  57.          this.ids.addElement(new Integer(this.field_0.addRecord(var1, 0, var1.length)));
  58.          return true;
  59.       } catch (Exception var3) {
  60.          return false;
  61.       }
  62.    }
  63.  
  64.    boolean setRecord(int var1, byte[] var2) {
  65.       try {
  66.          this.field_0.setRecord(var1, var2, 0, var2.length);
  67.          return true;
  68.       } catch (Exception var4) {
  69.          return false;
  70.       }
  71.    }
  72.  
  73.    boolean deleteRecord(int var1) {
  74.       try {
  75.          this.field_0.deleteRecord(var1);
  76.          this.ids.removeElementAt(this.getIndex(var1));
  77.          return true;
  78.       } catch (Exception var3) {
  79.          return false;
  80.       }
  81.    }
  82. }
  83.